<?php

 class __module_content extends __module_content_api {

    var $pages = array(
        false => "page_show",

        "show"    => "page_show",
        
        "block_Childs" => "block_Childs"
    );

    static $block_childs = false;

    static function e404($args = array()) {

        $id = __kernel_start::si('content')->getFromUri($_GET['m'], 'id');
        $id = $id['id'];
        if(!empty($id)) {
            return __kernel_start::si('content')->page_show(array($id));
        } else return __kernel_error::e404(true);

    }

    function page_show($args) {

    	if(!drv(ACSGP)->doIHaveAccess('view', 'content'))
    	
            if(isset($args[0]) && $args[0] !== false) $id = $args[0];
        elseif(isset($args[1]) && $args[1] !== false) $id = $this->getIdByUri($args[1]);
        elseif(isset($_GET['cid'])) $id = $_GET['cid'];

        if((string)$id != (string)((int)$id)) return "false";

        $content = $this->get($id, '', '', 1);
        $content = $content[0];


        if($content['cathegory'] == 1) {
            if($content['text'] == "") {
                __driver_display::si()->assign('child_list', $this->getChild($id));
                $content['text'] = __driver_display::si()->fetch(array('text_cat_list.html', new KT_start_moduleName('content')));
            } else {
                self::$block_childs = $id;
            }
        }

        return $this->showContent($content);

    }

    function block_Childs($args) {
        __driver_display::si()->assign('child_list', $this->getChild(self::$block_childs));
        return __driver_display::si()->fetch(array('block_Childs.html', new KT_start_moduleName('content')));
    }

    function showContent($content) {
               __driver_display::si()->assign('history', $this->getParents($content['id']));
               __driver_display::si()->assign('content', $content);
        return __driver_display::si()->fetch(array("content.html", new KT_start_moduleName('content')));

    }

 }

?>
